#include<iostream>
#include<vector>
using namespace std;
bool dfs(vector<vector<char>>& map, vector<vector<int>>& visited,int x,int y,int m,int n)
{
	int l1 = 0, l2 = 0;
	for (int i = x; i < m; i++)
	{
		
		if (map[i][y] == '#')l1=i;
		else break;
	}
	for (int j = y; j < n; j++)
	{
		if (map[x][j] == '#')l2=j;
		else break;
	}
	for (int i = x; i < l1; i++)
	{
		for (int j = y; j < l2; j++)
		{
			if (map[i][j] == '.')return false;
			else
			{
				visited[i][j] = true;

			}
		}
	}
	return true;
}
int main()
{
	int m, n;
	cin >> m >> n;
	vector<vector<char>> map(m, vector<char>(n));
	vector<vector<int>> visited(m, vector<int>(n));
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> map[i][j];
		}
	}
	int nums = 0;
	bool flag = 1;
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (map[i][j] == '#' && visited[i][j] == false)
			{
				if (!dfs(map, visited, i, j, m, n))
				{
					flag = 0;
					break;
				}
				else
				{
					nums++;
				}
			}
		}
		if (flag == 0)break;
	}
	if (flag == 0)cout << "Bad placement." << endl;
	else cout << "There are " << nums << " ships." << endl;
	return 0;
}